<template>
	<view class="container">
		<view class="list-cell b-b" @click="navTo('/pages/set/validatephone?phone='+user_info.phone)" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">手机号</text>
			<text class="cell-more yticon icon-you">{{user_info.phone}}</text>
		</view>
		<view class="list-cell" @click="navTo('/pages/set/setweixin?weixin_no='+user_info.weixin_no)" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">微信号</text>
			<text class="cell-more yticon icon-you">{{user_info.weixin_no}}</text>
		</view>
		<view class="list-cell" @click="navTo('/pages/set/setalipay')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">支付宝</text>
			<text class="cell-more yticon icon-you">
				<text v-if="user_info.alipay_account != ''">已设置</text>
			</text>
		</view>
		<view class="list-cell" @click="navTo('/pages/set/setpwd')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">设置密码</text>
			<text class="cell-more yticon icon-you">
				<text v-if="user_info.password != '' && user_info.password != null">已设置</text>
			</text>
		</view>
	</view>
</template>

<script>
	import apiuser from '../../common/api/user.js';
	import {mapMutations} from 'vuex';
	export default {
		data() {
			return {
				user_info:[],
			};
		},
		components: {
			apiuser,
		},
		onShow(){
			this.get_userinfo();
		},
		methods:{
			...mapMutations(['logout']),

			navTo(url){
				uni.navigateTo({
					url: url,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			//个人信息接口
			get_userinfo(){
				apiuser.get_userinfo({}).then(res =>{
					this.user_info = res.data;
					console.log(this.user_info)
				}).catch(res=>{
					
				});
			},
			//退出登录
			toLogout(){
				uni.showModal({
				    content: '确定要退出登录么',
				    success: (e)=>{
				    	if(e.confirm){
				    		this.logout();
				    		setTimeout(()=>{
				    			uni.navigateBack();
				    		}, 200)
				    	}
				    }
				});
			},
			//switch
			switchChange(e){
				let statusTip = e.detail.value ? '打开': '关闭';
				this.$api.msg(`${statusTip}消息推送`);
			},

		}
	}
</script>

<style lang='scss'>
	page{
		background: $page-color-base;
	}
	.avatar>image{
		width:50upx;
		height:50upx;
		border-radius:25upx;
	}
	.list-cell{
		display:flex;
		align-items:baseline;
		padding: 20upx $page-row-spacing;
		line-height:60upx;
		position:relative;
		background: #fff;
		justify-content: center;
		&.log-out-btn{
			margin-top: 40upx;
			.cell-tit{
				color: $uni-color-primary;
				text-align: center;
				margin-right: 0;
			}
		}
		&.cell-hover{
			background:#fafafa;
		}
		&.b-b:after{
			left: 30upx;
		}
		&.m-t{
			margin-top: 16upx; 
		}
		.cell-more{
			align-self: baseline;
			font-size:$font-lg;
			color:$font-color-light;
			margin-left:10upx;
		}
		.cell-tit{
			flex: 1;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			margin-right:10upx;
		}
		.cell-tip{
			font-size: $font-base;
			color: $font-color-light;
		}
		switch{
			transform: translateX(16upx) scale(.84);
		}
	}
</style>
